using System;
using System.ComponentModel;
using System.Globalization;
namespace Microsoft.Phone.Controls.Maps.Design
{
	public class LocationRectConverter : TypeConverter
	{
		public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
		{
			return sourceType == typeof(string);
		}
		public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
		{
			string text = value as string;
			if (text == null)
			{
				throw new NotSupportedException(ExceptionStrings.TypeConverter_InvalidLocationRectFormat);
			}
			string[] array = text.Split(new char[]
			{
				','
			});
			if (array.Length == 4)
			{
				return new LocationRect(double.Parse(array[0], CultureInfo.get_InvariantCulture()), double.Parse(array[1], CultureInfo.get_InvariantCulture()), double.Parse(array[2], CultureInfo.get_InvariantCulture()), double.Parse(array[3], CultureInfo.get_InvariantCulture()));
			}
			throw new FormatException(ExceptionStrings.TypeConverter_InvalidLocationRectFormat);
		}
	}
}
